<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->

<html>
    <head>
        <meta charset="UTF-8">
        <title>注册页面</title>
    </head>
    <body>
        <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
            用户名：<input name="user" id="user">
            <br><br>
            密码：<input name="pwd" id="pwd" type="password">
            <br><br>
            <input type="submit" name="submit" value="提交">
            <input type="button" value="返回" onclick="window.location.href = 'index.php'">
        </form>
        <?php
        require 'lyb_conn.php';
        if (isset($_POST['submit'])) {
            $pwd = password_hash($_POST[pwd], PASSWORD_BCRYPT);
            $sql = "insert into n2(user,pwd,auth) values('$_POST[user]','$pwd','5')";
            mysqli_query($con, $sql);
            echo "<script type='text/javascript'>window.location.href='index.php'</script>";
        }
        ?>
    </body>
</html>
